/*
 * Created on Jun 3, 2005
 *
 */
package com.erclab.internal.xpresso.handlers;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.erclab.internal.xpresso.security.*;

import org.apache.commons.dbutils.ResultSetHandler;

/**
 * @author Enrique Rodriguez.
 *
 */
public class UserRolesHandler implements ResultSetHandler {

	private User theUser;

	public UserRolesHandler(User user){
		theUser = user;
	}
	

	/* (non-Javadoc)
	 * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
	 */
	public Object handle(ResultSet rs) throws SQLException {
		ArrayList roles = new ArrayList();
		while (rs.next()){
			roles.add(rs.getString(1));
		}
		theUser.setRoles((String[])roles.toArray(new String[roles.size()]));
		return null;	
	}

}
